<?php
class TuVungController extends AppController {
	
	public $uses = array('QuanHeModel', 'TuVungModel');
	
	public $dsThamSo = array('loaiTu', 'baiHoc', 'loaiKiemTra', 'nhomTu');
	
	public function kiemtra() {
	    
	    // danh sach bien
	    $dsLoaiTu 		= array(); // danh sach loai tu
        $dsBaiHoc 		= array(); // danh sach bai hoc
        $dsTuVung 		= array(); // danh sach tu vung
        $dsLoaiKiemTra 	= array(); // danh sach loai kiem tra
        $dsNhomTu 		= array(); // danh sach loai kiem tra
        
        $thamsoForm 	= $this->getFormParameters($this->dsThamSo, array()); //debug($thamsoForm);
		// lay du lieu tu database
        $dsLoaiTu 		= $this->QuanHeModel->layDanhSachTheoLoai('LOAI_TU',$thamsoForm['loaiTu']);
        $dsBaiHoc 		= $this->QuanHeModel->layDanhSachTheoLoai('BAI_HOC',$thamsoForm['baiHoc']);
		$dsLoaiKiemTra 	= $this->QuanHeModel->layDanhSachTheoLoai('LOAI_KIEM_TRA',$thamsoForm['loaiKiemTra']);
		$dsNhomTu 		= $this->QuanHeModel->layDanhSachTheoLoai('NHOM_TU',$thamsoForm['nhomTu']);
	    // kiem tra trang thai post back
		if($this->request->is('post')) {
			// lay danh sach tu vung theo dieu kien
			$dsTuVung 		= $this->TuVungModel->layDanhSachTuVungTheoDieuKien($thamsoForm);
		}// ket thuc kiem tra trang thai post back
		
		// truyen du lieu den view
		$this->set(compact('dsLoaiTu', 'dsBaiHoc', 'dsLoaiKiemTra', 'dsTuVung', 'dsNhomTu'));
	}
}